import android.graphics.Color
import android.view.View
import androidx.annotation.ColorInt
import androidx.annotation.DrawableRes
import androidx.appcompat.app.AppCompatActivity
import com.asman.worker.R

fun androidx.appcompat.widget.Toolbar.init(
    context: AppCompatActivity?,
    @DrawableRes navigationIcon: Int = R.drawable.ic_arrow_back_black_24dp,
    title: String? = "",
    @ColorInt backgroundColor: Int = Color.parseColor("#ffffff"),
    @ColorInt titleTextColor: Int = Color.parseColor("#333333"),
    backClickListener: View.OnClickListener = View.OnClickListener { context?.onBackPressed() }
) {
    context?.setSupportActionBar(this)
    setNavigationIcon(navigationIcon)
    setBackgroundColor(backgroundColor)
    setTitleTextColor(titleTextColor)
    setNavigationOnClickListener {
        backClickListener.onClick(it)
    }
    context?.supportActionBar?.title = title
}